<?php

/*
 * Copyright Domenic Helfenstein
 */
define('DATA_XML', 'xml/data.xml');
define('WEB_UPLOADED_FOLDER', 'http://gastro-project.philippjenni.ch/uploaded/');

function insertIntoXML($event, $imageName) {
   $xml = simplexml_load_file(DATA_XML);
   $eventNode = $xml->addChild('event');
   $eventNode->addChild('name', $event['title']);
   $eventNode->addChild('maxRegistrations', '10');
   $eventNode->addChild('from', $event['begin']);
   $eventNode->addChild('to', $event['end']);
   $eventNode->addChild('description', $event['description']);
   $eventNode->addChild('picturePath', WEB_UPLOADED_FOLDER.$imageName);
   persistXML(DATA_XML, $xml);
}

function persistXML($path, $xml) {
   file_put_contents($path, $xml->asXML());
}

?>
